<?php

/**
 * 安心站长axzz.cn，一个追求技术创造者。让网站、小程序、APP牛起来……
 *
 * cighsen02 365182575
 * 
 * Create at: 2024.05.06
 * Update at: 2025.08.23
*/

namespace Twoir\Service\ShowKey;

use Exception;

/**
 * 验证码接口
 */
interface OutputInterface
{
    const WIDTH = 47;

    const HEIGHT = 20;

    const MIME = [
        'jpg'   => 'image/jpeg',
        'jpeg'  => 'image/jpeg',
        'png'   => 'image/png',
        'gif'   => 'image/gif',
        'wbmp'  => 'image/vnd.wap.wbmp'
    ];

    const VERIFY_KEY = [
        // 登陆
        'login'			=> 'checkloginkey',
        // 注册
        'reg'			=> 'checkregkey',
        'info'			=> 'checkinfokey',
        'spacefb'		=> 'checkspacefbkey',
        'spacegb'		=> 'checkspacegbkey',
        'gbook'			=> 'checkgbookkey',
        'feedback'		=> 'checkfeedbackkey',
        'getpassword'	=> 'checkgetpasskey',
        'regsend'		=> 'checkregsendkey',
        'report' 		=> 'checkreportkey',
        // 评论
        'pl'			=> 'checkplkey'
    ];
    // 默认颜色
    const DEFAULT_RGB = [
        // 背景色
        'keybgcolor' 	=> [102, 102, 102],
        // 文字色
        'keyfontcolor'	=> [255, 255, 255],
        // 干扰色
        'keydistcolor'	=> [71, 71, 71]
    ];
    /**
     * 验证码渲染
     *
     * @param array $add
     * @return string
     * 
     * @throws Exception
    */
    public function render(array $add): string;

    /**
     * 生成图像
     *
     * @param array $add
     * @param bool $imageBase64
     * @return string
     * 
     * @throws Exception
    */
    public function base64DataURI(array $add, bool $imageBase64 = true): string;
}
